package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	InquiryEventNew           = "erp.InquiryNew"
	InquiryEventBeforeCreate  = "erp.InquiryBeforeCreate"
	InquiryEventBeforeUpdate  = "erp.InquiryBeforeUpdate"
	InquiryEventBeforeSave    = "erp.InquiryBeforeCreate erp.InquiryBeforeUpdate"
	InquiryEventAfterCreate   = "erp.InquiryAfterCreate"
	InquiryEventAfterUpdate   = "erp.InquiryAfterUpdate"
	InquiryEventAfterSave     = "erp.InquiryAfterCreate erp.InquiryAfterUpdate"
	InquiryEventDelete        = "erp.InquiryDelete"
	InquiryAccessControlEvent = "erp.InquiryAccessControl"
)

func GetInquiryConfig() *mgo.DocConfig {
	return Inquiry_Config
}

var Inquiry_Config *mgo.DocConfig

func init() {
	Inquiry_Config = NewInquiryConfig()
}
func NewInquiryConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "erp.Inquiry",
		Fields: []string{
			"sn", "title", "payType", "deliver", "contactEmp", "contact", "contactPhone", "status", "isCancel", "isClose", "isConfirm", "confirmAt", "formAt", "formEmp", "createEmp", "note", "product",
		},
		RelationFields: []string{
			"payType", "contactEmp", "status", "formEmp", "createEmp", "product",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"payType": {
				Config:     GetPayTypeConfig,
				DocName:    "PayType",
				JoinType:   "O",
				KeyInside:  "payTypeId",
				KeyOutSide: "id",
			},
			"contactEmp": {
				Config:     GetEmpConfig,
				DocName:    "Emp",
				JoinType:   "O",
				KeyInside:  "contactEmpId",
				KeyOutSide: "id",
			},
			"status": {
				Config:     GetInquiryStatusConfig,
				DocName:    "InquiryStatus",
				JoinType:   "O",
				KeyInside:  "statusId",
				KeyOutSide: "id",
			},
			"formEmp": {
				Config:     GetEmpConfig,
				DocName:    "Emp",
				JoinType:   "O",
				KeyInside:  "formEmpId",
				KeyOutSide: "id",
			},
			"createEmp": {
				Config:     GetEmpConfig,
				DocName:    "Emp",
				JoinType:   "O",
				KeyInside:  "createEmpId",
				KeyOutSide: "id",
			},
			"product": {
				Config:     GetInquiryProductConfig,
				DocName:    "InquiryProduct",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "belongToId",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
